public class CpuNum {
    public static void main(String[] args) {
        Runtime runtime = Runtime.getRuntime();
        //获取当前电脑cpu数量
        int cpuNums = runtime.availableProcessors(); //返回Java虚拟机可用的处理器数量
        System.out.println("当前电脑cpu数量为:" + cpuNums);
    }
}
